#include "utils.h"
#include <stdio.h>

/* Merge two lists of DNA strings.
 *
 * Preconditions: (responsibility to the caller)
 *	- dstSize and srcSize are smaller than the size of each respective list
 *	(i.e. overflow not checked here)
 *
 * Behaviour:
 *	Merges the two lists. All unused elements of source list end up copied in
 *	destination list. The usedFlag is reset in all elements of the destination list.
 *	The source list is left unchanged.
 */

void mergeLists(DnaSeq *dst, size_t& dstSize, const DnaSeq *src, const size_t src_Size)
{
	int dstOffset=0;
	for (int i=0; i < src_Size; i++) {
		if ( src[i].flag==0 && src[i].len !=0 ) {
			dst[dstSize+dstOffset].len=src[i].len;
			dst[dstSize+dstOffset].flag=0;
			for (int j=0; j < src[i].len; j++)
				dst[dstSize+dstOffset].nucl[j]=src[i].nucl[j];
			dstOffset++;
		}
	}
	dstSize+=dstOffset;
}
/*
void mergeLists2(vector<DnaSeq>& dst, size_t& dstSize, const DnaSeq * src, const size_t srcSize)
{
	vector<DnaSeq> tmp;

}
*/
void emptyList(DnaSeq *lst, size_t totalLstSz)
{
	for(int i=0; i<totalLstSz; i++){
		lst[i].flag=0;
		lst[i].len=0;
		snprintf(lst[i].nucl, sizeof(lst[i].nucl), (char)0);
	}
}

